<!DOCTYPE html>
<html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml" xmlns:v-on="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>demo</title>
    <script src="../common/vue.min.js" type="text/javascript"></script>
    <style type="text/css">

    </style>
</head>
<body>
<!--view-->
<div id="e2">
    <!--一个限制是每个绑定只能包含单个表达式-->
    <div>{{b+1}}</div>
    <div>{{b*1+1}}</div>
    <hr/>
    <div>{{c+1}}</div>
    <div>首字母大写： {{ e | capitalize}}</div>
    <hr/>
    指令：
    <div v-if="a">指令生效a=true</div>
    <div v-if="c==1">指令生效c==1</div>

    <hr/>
    <a v-bind:href="url">百度</a>
    <a :href="url">百度</a>

    <a @click="doSomething">点击事件1</a>
    <a v-on:click="doSomething">点击事件2</a>

    <hr/>
    <div class="static" v-bind:class="cssData1">
        cssData1
    </div>
    <div class="static" v-bind:class=" { 'class-a':isA,'class-b':isB }">
        cssData2
    </div>


</div>


<script type="text/javascript">


    /**
     *
     */
    var vm = new Vue({
        el: '#e2', //el :element
        data: {
            a: true,
            raw_html: "<span style='color: red'><b>你好啊</b></span>",
            b: "1",
            c: 1,
            d: 2,
            e: "reese",
            url: "http://www.baidu.com",
            cssData1: {
                'class-a': true,
                'class-b': false
            },
            cssData2: {
                isA: false,
                isB: true
            }
        },
        //TODO 钩子是什么
        //vm实例创建后的钩子
        created: function () {
            console.log(this);//vm实例
            console.log("a1:" + this.a);
            console.log("a2:" + this.$data.a);
            console.log(this.a == this.$data.a);
        }
    })
    //    vm.$data.a = false;

    //TODO 点击后不执行
    function doSomething() {
        alert(1);
        alert(vm.$data.url);
    }


</script>

</body>
</html>